package io.renren.modules.generator.controller;

import java.io.IOException;
import java.util.*;
import java.util.logging.Logger;
import com.alibaba.fastjson.JSONArray;
import io.renren.common.utils.ExportExcel;
import io.renren.modules.combat.entity.TFightPeopleEntity;
import io.renren.modules.generator.entity.*;
import io.renren.modules.generator.entity.vo.TTrainingVo;
import io.renren.modules.user.entity.form.PeopleEntityForm;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.generator.service.TTrainingService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;

import javax.servlet.http.HttpServletResponse;


/**
 * 训练表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-08-07 13:58:41
 */
@RestController
@RequestMapping("/ttraining")
public class TTrainingController {
    @Autowired
    private TTrainingService tTrainingService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("generator:ttraining:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = tTrainingService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 列表
     */
    @RequestMapping("/selectTTraining")
    @ResponseBody
    @RequiresPermissions("generator:tobject:selectTTraining")
    public R selectList(@RequestBody TTrainingEntity trainingEntity){
        String sql = this.doSql(trainingEntity.getPeopleEntityForms(),trainingEntity.getFlag());
        Map<String,Object> params=new HashMap<String,Object> ();
        String sqls=null;
        if(!sql.equals("")){
            String a=sql.substring(0,3);
            if("and".equals(a)){
                sqls = deleteAssignChar(sql, 0, 'a');
                String sa = deleteAssignChar(sqls, 1, 'a');
                String sb = deleteAssignChar(sa, 1, 'n');
                sqls = deleteAssignChar(sb, 1, 'd');
            }
            if("or ".equals(a)){
                sqls = deleteAssignChar(sql, 0, 'o');
                String sa = deleteAssignChar(sqls, 1, 'o');
                sqls = deleteAssignChar(sa, 1, 'r');
            }
            System.out.print(sqls);
        }
        params.put("sqls",sqls);
        params.put("page",trainingEntity.getPage());
        params.put("limit",trainingEntity.getLimit());
        params.put("name",trainingEntity.getName());
        params.put("detachment",trainingEntity.getDetachment());
        params.put("month",trainingEntity.getMonth());
        params.put("zmonth",trainingEntity.getZmonth());
        params.put("trainType",trainingEntity.getTrainType());
        params.put("squadron",trainingEntity.getSquadron());
        Integer trainTypes=trainingEntity.getTrainTypes();
        params.put("trainTypes",trainTypes);
        PageUtils page = tTrainingService.selectTTraining(params);
        return R.ok().put("page", page);

    }

    public static String deleteAssignChar(String str, int on, char c){
        int count = 0;
        for(int i=0;i<str.length();i++){
            if(str.charAt(i) == c){
                count++;
                if(count == on){
                    str = str.substring(0, i) + str.substring(i + 1);
                }
            }
        }
        return str;
    }


    /**
     *   历时成绩 最新一条成绩  修改 回显数据
     */
    @RequestMapping("/info")
    @ResponseBody
    //@RequiresPermissions("generator:ttraining:info")
    public R info(@RequestBody TTrainingEntity trainingEntity){
        TTrainingEntity listTraining=tTrainingService.getHxTTraining(trainingEntity.getId());
        List<TTrainingObjectEntity> listObject=tTrainingService.getHxTTrainingObject(trainingEntity.getId());
        List<TTrainingPeopleEntity> listPeople=tTrainingService.getTTrainingPeople(trainingEntity.getId());
        List<TTrainingDictionaryEntity> level=tTrainingService.getLevel();   //层级
        List<TTrainingDictionaryEntity> datachment=tTrainingService.getDatachment();  //目的
        //List<TTrainingDictionaryEntity> purpose=tTrainingService.getPurpose();   //组织单位
        List<TTrainingDictionaryEntity> trainType=tTrainingService.getTrainType();   //训练类型
        return R.ok().put("listTraining", listTraining).put("listObject",listObject).put("listPeople",listPeople).put("datachment",datachment).put("trainType",trainType);
    }

    /**
     * 导入成绩
     */
    @RequestMapping("/infoList")
    @ResponseBody
    @RequiresPermissions("generator:ttraining:infoList")
    public R infoList(@RequestBody TTrainingEntity trainingEntity){
        TTrainingEntity listTraining=tTrainingService.getHxTTraining(trainingEntity.getId());
        List<TTrainingObjectEntity> listObject=tTrainingService.getHxTTrainingObject(trainingEntity.getId());
        List<TTrainingPeopleEntity> listPeople=tTrainingService.getTTrainingPeople(trainingEntity.getId());
        List<TTrainingDictionaryEntity> level=tTrainingService.getLevel();   //层级
        List<TTrainingDictionaryEntity> datachment=tTrainingService.getDatachment();  //目的
        //List<TTrainingDictionaryEntity> purpose=tTrainingService.getPurpose();   //组织单位
        List<TTrainingDictionaryEntity> trainType=tTrainingService.getTrainType();   //训练类型
        return R.ok().put("listTraining", listTraining).put("listObject",listObject).put("listPeople",listPeople).put("datachment",datachment).put("trainType",trainType);
    }

    /**
     * 下拉框
     */
    @RequestMapping("/xlks")
    //@RequiresPermissions("generator:ttraining:xlks")
    public R xlks(){
        List<TTrainingDictionaryEntity> level=tTrainingService.getLevel();   //层级
        List<TTrainingDictionaryEntity> datachment=tTrainingService.getDatachment();  //目的
        //List<TTrainingDictionaryEntity> purpose=tTrainingService.getPurpose();   //组织单位
        List<TTrainingDictionaryEntity> trainType=tTrainingService.getTrainType();   //训练类型
        return R.ok().put("level",level).put("datachment",datachment).put("trainType",trainType);
    }
    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("generator:ttraining:save")
    public R save(@RequestBody TTrainingEntity tTraining){
		//tTrainingService.save(tTraining);
        tTrainingService.insertTTraining(tTraining);
        tTrainingService.insertTTrainingObject(tTraining.getList());
        tTrainingService.insertTTrainingPeople(tTraining.getListPeople());
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("generator:ttraining:update")
    public R update(@RequestBody TTrainingEntity tTraining){
		tTrainingService.updateTTrainingEntity(tTraining);
        Integer num=tTraining.getList().size();
        Integer aum=tTraining.getListPeople().size();
        for(int i=0;i<num;i++){
            Integer sum= tTraining.getList().get(i).getId();
            if(tTraining.getList().get(i).getId()==null){
                TTrainingObjectEntity list=tTraining.getList().get(i);
                list.setTiainingId(tTraining.getId());
                tTrainingService.addTTrainingObject(list);
            }else{
            }
        }
        for(int i=0;i<aum;i++){
            Integer um= tTraining.getListPeople().get(i).getId();
            if(tTraining.getListPeople().get(i).getId()==null){
                TTrainingPeopleEntity list=tTraining.getListPeople().get(i);
                list.setTrainingId(tTraining.getId());
                tTrainingService.addTTrainingPeople(list);
            }else{

            }
        }
        return R.ok();
    }

    /**
     * 修改 合格率
     */
    @RequestMapping("/updateQualificationrate")
    //@RequiresPermissions("generator:ttraining:update")
    public R updateQualificationrate(@RequestBody TTrainingEntity tTraining){
        tTrainingService.updateQualificationrate(tTraining);
        return R.ok();
    }

    /**
     * 删除 训练信息
     */
    @RequestMapping("/delete")
    @RequiresPermissions("generator:ttraining:delete")
    public R delete(@RequestBody TTrainingEntity trainingEntity){
		tTrainingService.delTTrainingEntity(trainingEntity.getId());
        return R.ok();
    }
    /**
     * 删除 训练科目
     */
    @RequestMapping("/deleteObject")
    //@RequiresPermissions("generator:ttraining:deleteObject")
    public R deleteObject(@RequestBody TTrainingEntity trainingEntity){
        tTrainingService.delTTrainingObjectEntity(trainingEntity.getId());
        return R.ok();
    }
    /**
     * 删除 训练人员
     */
    @RequestMapping("/deletePeople")
    //@RequiresPermissions("generator:ttraining:deletePeople")
    public R deletePeople(@RequestBody TTrainingEntity trainingEntity){
        tTrainingService.delTTrainingPeopleEntity(trainingEntity.getId());
        return R.ok();
    }

    //导出
    String title = "注:时间用小数点";
    String[] rowsName;  //数据头部；
    List<Object[]>  dataList;
    @RequestMapping("/export")
    //@RequiresPermissions("generator:ttraining:export")
    @ApiOperation(value = "导出报表", httpMethod = "GET", notes = "导出报表,前端写一个导出地址调用此接口即可")
    public R exportLyHjch(Integer id,HttpServletResponse response) throws IOException {
        TTrainingEntity trainingEntity=new TTrainingEntity();
        trainingEntity.setId(id);
        List<TTrainingVo> voList = tTrainingService.DcTTraining(trainingEntity);
        List<Map<String,Object>> mapList = tTrainingService.DcTTrainingMap(trainingEntity);
        Logger.getLogger("获取全部列表数据"+JSONArray.toJSON(voList));
        int a=0;
        //int m=mapList.get(0).size()+(mapList.get(0).size()-3);
        //int l=mapList.get(0).size()-3;
        rowsName= new String[mapList.get(0).size()];
//        for (Map.Entry<String, Object> entry : mapList.get(0).entrySet()) {
//            rowsName[a]=entry.getKey();
//            a++;
//            if(a>3){
//                rowsName[a]="完成标准";
//                a++;
//            }
//        }
        for (Map.Entry<String, Object> entry : mapList.get(0).entrySet()) {
            rowsName[a]=entry.getKey();
            a++;
        }
        for(int i = 0; i < rowsName.length; i++){
            String name = rowsName[i];
            String[] value = name.split(",");
            if(value[0].equals("id")){
                String temp = rowsName[0];
                rowsName[0] = rowsName[i];
                rowsName[i] = temp;
            }
            if(value[0].equals("name")){
                String temp = rowsName[1];
                rowsName[1] = rowsName[i];
                rowsName[i] = temp;
            }
            if(value[0].equals("idcard")){
                String temp = rowsName[2];
                rowsName[2] = rowsName[i];
                rowsName[i] = temp;
            }
        }
        System.out.println(rowsName);
        dataList = new ArrayList<>();
        Object[] objs;
        for (int i = 0; i < voList.size(); i++) {
            TTrainingVo trainingVo=voList.get(i);
//            int num=rowsName.length+(rowsName.length-3);
//            int l=rowsName.length-3;
            objs = new Object[rowsName.length];
            objs[0]=trainingVo.getId();
            objs[1]=trainingVo.getName();
            objs[2]=trainingVo.getIdcard();
            for(int s=3;s<mapList.get(0).size();s++){
                objs[s]=0;
            }
            dataList.add(objs);
        }
        try{
            ExportExcel ex = new ExportExcel(title, rowsName, dataList);
            ex.export();
        }catch(Exception e){
            System.out.println("Wrong!");
        }
        return R.ok().put("dataList",dataList).put("rowsName",rowsName);

    }

//    /**
//     * 导出数据  测试暂时没有到
//     */
//    @RequestMapping("/ining")
//    public R qwe(){
//        try{
//            ExportExcel ex = new ExportExcel(title, rowsName, dataList);
//            ex.export();
//        }catch(Exception e){
//            System.out.println("Wrong!");
//        }
//            return R.ok();
//    }

    /**
     * 分布图 支队
     */
    @RequestMapping("/getSYtraining")
    //@RequiresPermissions("generator:ttraining:getSYtraining")
    public R getSYtraining(@RequestBody TTrainingEntity tTraining){
        List<TTrainingEntity> list=tTrainingService.getSYtraining(tTraining);
        return R.ok().put("list", list);
    }
    /**
     * 分布图 中队
     */
    @RequestMapping("/getZdtraining")
    //@RequiresPermissions("generator:ttraining:getSYtraining")
    public R getZdtraining(@RequestBody TTrainingEntity tTraining){
        List<TTrainingEntity> list=tTrainingService.getZdtraining(tTraining);
        return R.ok().put("list", list);
    }

    /**
     * 训练头部 所有支队总计
     * @param
     * @return
     */
    @RequestMapping("/totalTrainingDetachment")
    //@RequiresPermissions("generator:ttraining:getSYtraining")
    public R totalTrainingDetachment(@RequestBody TTrainingEntity tTraining){
        List<TTrainingEntity> list=tTrainingService.totalTrainingDetachment(tTraining);
        return R.ok().put("list", list);
    }

    /**
     * 训练头部 所有支队总计
     * @param
     * @return
     */
    @RequestMapping("/headCount")
    //@RequiresPermissions("generator:ttraining:headCount")
    public R headCount(@RequestBody TTrainingEntity tTraining){
        List<TTrainingEntity> list=tTrainingService.headCount(tTraining);
        return R.ok().put("list", list);
    }

    /**
     * 训练头部 所有中队总计
     * @param tTraining
     * @return
     */
    @RequestMapping("/totalTrainingSquadron")
    //@RequiresPermissions("generator:ttraining:getSYtraining")
    public R totalTrainingSquadron(@RequestBody TTrainingEntity tTraining){
        List<TTrainingEntity> list=tTrainingService.totalTrainingSquadron(tTraining);
        return R.ok().put("list", list);
    }


    /*
     * 拼接sql
     * */
    private String doSql(List<PeopleEntityForm> tPeopleEntityList, String flag){
        StringBuffer sqlString=new StringBuffer();
        if(tPeopleEntityList !=null){
            if("0".equals(flag)) {
                for (PeopleEntityForm tPeopleForm : tPeopleEntityList) {
                    if ("name".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and t.name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and t.name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("datachment".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and t.datachment " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and t.datachment " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("level".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and t.level " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and t.level " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("purpose".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and t.purpose " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and t.purpose " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("startTime".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and t.start_time " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and t.start_time " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("endTime".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and t.end_time " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and t.end_time " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("stuation".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and t.stuation " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and t.stuation " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("countPeople".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and t.count_people " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and t.count_people " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("trainType".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and t.train_type " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and t.train_type " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("datachmentName".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and a.type_name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and a.type_name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("levelName".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and b.detachment " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and b.detachment " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("purposeName".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and c.detachment " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and c.detachment " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("trainTypeName".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and d.type_name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and d.type_name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("qualificationrate".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and t.qualificationrate " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and t.qualificationrate " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                }
            } else{
                for (PeopleEntityForm tPeopleForm : tPeopleEntityList) {
                    if ("name".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or t.name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or t.name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("datachment".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or t.datachment " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or t.datachment " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("level".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or t.level " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or t.level " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("purpose".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or t.purpose " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or t.purpose " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("startTime".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or t.start_time " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or t.start_time " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("endTime".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or t.end_time " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or t.end_time " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("stuation".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or t.stuation " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or t.stuation " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("countPeople".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or t.count_people " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or t.count_people " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("trainType".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or t.train_type " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or t.train_type " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("datachmentName".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or a.type_name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or a.type_name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("levelName".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or b.type_name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or b.type_name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("purposeName".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or c.type_name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or c.type_name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("trainTypeName".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or d.type_name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or d.type_name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("qualificationrate".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or t.qualificationrate " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or t.qualificationrate " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                }
            }
        }
        return sqlString.toString();
    }
}
